# ICX Switch Script with Posh-SSH #This script uses the credentials user1 and userpassword to SSH into switch 10.0.0.1 #and execute the show interface brief command and save the output to a file called #output.txt in the same directory as the script. # # Enter user credentials into the script $User = "user1" $PWord = ConvertTo-SecureString -String "userpassword" -AsPlainText -Force $Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord #Open the SSH session New-SSHSession -ComputerName 10.0.0.1 -Credential ($Credential) -Verbose $SSHStream = New-SSHShellStream -Index 0 #Break to establish session sleep 10 # Write commands to the switch $SSHStream.WriteLine("skip-page-display") $SSHStream.WriteLine("sh int bri") sleep 2 # Write output to a file Out-File -FilePath .\output.txt -InputObject $SSHStream.Read() # End SSH session Remove-SSHSession -Index 0